import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		token: '',
		addressName: null,
		user: null,
		lat: '',
		lng: '',
		uaddress: null
	},
	mutations: {
		login(state, provider) {
			state.token = provider;
			uni.setStorage({
				key: 'token',
				data: provider
			})
		},
		setUserInfo(state, provider) {
			state.user = provider
		},
		logout(state) {
			state.token = '';
			uni.removeStorage({
				key: 'token'
			})
		},
		setaddress(state, provider) {
			state.addressName = provider
		}
	},
	actions: {

	}
})

export default store
